package view;

import util.ManipulacaoData;
import controller.IFornecedorCtrl;
import java.awt.event.KeyEvent;
import java.sql.Date;
import java.util.ArrayList;
import javax.swing.DefaultComboBoxModel;
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
import model.IFornecedor;
import model.Observer;

public class FornecedorGUI extends javax.swing.JFrame implements Observer{

    private IFornecedor model;
    private IFornecedorCtrl fornecedorCtrl;  
    private ManipulacaoData mDate = new ManipulacaoData();    
             
    public FornecedorGUI(IFornecedor model,IFornecedorCtrl fornecedorCtrl) {
        this.fornecedorCtrl = fornecedorCtrl;       
        this.model = model;    
        this.model.registrarObserver(this);                                 
    }

    @SuppressWarnings("unchecked")    
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel7 = new javax.swing.JLabel();
        jPanel3 = new javax.swing.JPanel();
        jcbxPesquisa = new javax.swing.JComboBox();
        jtfdPesquisa = new javax.swing.JTextField();
        jScrollPane1 = new javax.swing.JScrollPane();
        jtblPesquisa = new javax.swing.JTable();
        jbtnPesquisar = new javax.swing.JButton();
        jSeparator12 = new javax.swing.JSeparator();
        jSeparator13 = new javax.swing.JSeparator();
        jLabel10 = new javax.swing.JLabel();
        jPanel1 = new javax.swing.JPanel();
        jtfdNome = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        jtfdCodigo = new javax.swing.JTextField();
        jLabel12 = new javax.swing.JLabel();
        jtfdOrgao = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        jtfdEmail = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        jtfdCnpj = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        jtfdCelular = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        jtfdCpf = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        jtfdRg = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        jtfdTelefone = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jtfdFax = new javax.swing.JTextField();
        jLabel13 = new javax.swing.JLabel();
        jtfdContato = new javax.swing.JTextField();
        jLabel14 = new javax.swing.JLabel();
        jtfdDataCadastro = new javax.swing.JTextField();
        jPanel4 = new javax.swing.JPanel();
        jtfdBairro = new javax.swing.JTextField();
        jtfdEndereco = new javax.swing.JTextField();
        jLabel15 = new javax.swing.JLabel();
        jtfdCidade = new javax.swing.JTextField();
        jLabel17 = new javax.swing.JLabel();
        jLabel18 = new javax.swing.JLabel();
        jtfdUf = new javax.swing.JTextField();
        jtfdCep = new javax.swing.JTextField();
        jLabel19 = new javax.swing.JLabel();
        jLabel20 = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        jtaObs = new javax.swing.JTextArea();
        jLabel16 = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        jbtnCancelar = new javax.swing.JButton();
        jbtnExcluir = new javax.swing.JButton();
        jbtnSalvar = new javax.swing.JButton();
        jbtnNovo = new javax.swing.JButton();
        jbtnPrimeiro = new javax.swing.JButton();
        jbtnAnterior = new javax.swing.JButton();
        jbtnProximo = new javax.swing.JButton();
        jbtnUltimo = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Controle de Fornecedores");
        setMinimumSize(new java.awt.Dimension(745, 615));
        setResizable(false);

        jLabel7.setBackground(new java.awt.Color(0, 0, 0));
        jLabel7.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N
        jLabel7.setForeground(new java.awt.Color(0, 0, 255));
        jLabel7.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel7.setText("Controle de Fornecedores");

        jPanel3.setBackground(new java.awt.Color(217, 228, 231));
        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.RAISED, new java.awt.Color(102, 0, 255), new java.awt.Color(102, 0, 255)), "Fornecedores", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 1, 12), java.awt.Color.black)); // NOI18N
        jPanel3.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jcbxPesquisa.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jcbxPesquisa.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        jPanel3.add(jcbxPesquisa, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 40, 110, 20));

        jtfdPesquisa.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jtfdPesquisa.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jtfdPesquisaKeyReleased(evt);
            }
        });
        jPanel3.add(jtfdPesquisa, new org.netbeans.lib.awtextra.AbsoluteConstraints(150, 40, 390, 20));

        jtblPesquisa.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jtblPesquisa.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Título 1", "Título 2", "Título 3", "Título 4"
            }
        ));
        jtblPesquisa.setName("");
        jtblPesquisa.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jtblPesquisaMouseClicked(evt);
            }
        });
        jtblPesquisa.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jtblPesquisaKeyReleased(evt);
            }
        });
        jScrollPane1.setViewportView(jtblPesquisa);

        jPanel3.add(jScrollPane1, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 70, 640, 90));

        jbtnPesquisar.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jbtnPesquisar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icones/pesquisar.png"))); // NOI18N
        jbtnPesquisar.setMnemonic('C');
        jbtnPesquisar.setText("Buscar");
        jbtnPesquisar.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        jbtnPesquisar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtnPesquisarActionPerformed(evt);
            }
        });
        jPanel3.add(jbtnPesquisar, new org.netbeans.lib.awtextra.AbsoluteConstraints(560, 30, 100, 30));

        jSeparator12.setOrientation(javax.swing.SwingConstants.VERTICAL);
        jPanel3.add(jSeparator12, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 40, -1, 20));

        jSeparator13.setOrientation(javax.swing.SwingConstants.VERTICAL);
        jPanel3.add(jSeparator13, new org.netbeans.lib.awtextra.AbsoluteConstraints(550, 40, 10, 20));

        jLabel10.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel10.setText("Pesquisar Por:");
        jPanel3.add(jLabel10, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 20, 130, -1));

        jPanel1.setBackground(new java.awt.Color(217, 228, 231));
        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(new java.awt.Color(102, 0, 255), new java.awt.Color(102, 0, 255)), "Dados do Fornecedor", javax.swing.border.TitledBorder.LEFT, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 12), new java.awt.Color(0, 0, 0))); // NOI18N
        jPanel1.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jtfdNome.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jtfdNome.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jtfdNomeKeyReleased(evt);
            }
        });
        jPanel1.add(jtfdNome, new org.netbeans.lib.awtextra.AbsoluteConstraints(120, 40, 430, -1));

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jLabel1.setText("Nome:");
        jPanel1.add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(120, 20, -1, 20));

        jtfdCodigo.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jtfdCodigo.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        jtfdCodigo.setEnabled(false);
        jPanel1.add(jtfdCodigo, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 40, 80, 20));

        jLabel12.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jLabel12.setText("Código:");
        jPanel1.add(jLabel12, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 20, -1, 20));

        jtfdOrgao.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jtfdOrgao.setText("SSP-BA");
        jtfdOrgao.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jtfdOrgaoKeyReleased(evt);
            }
        });
        jPanel1.add(jtfdOrgao, new org.netbeans.lib.awtextra.AbsoluteConstraints(250, 120, 60, 20));

        jLabel2.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jLabel2.setText("Orgão:");
        jPanel1.add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(250, 100, 50, 20));

        jtfdEmail.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jtfdEmail.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jtfdEmailKeyReleased(evt);
            }
        });
        jPanel1.add(jtfdEmail, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 80, 370, 20));

        jLabel3.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jLabel3.setText("E-mail:");
        jPanel1.add(jLabel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 60, 60, 20));

        jtfdCnpj.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jtfdCnpj.setText("07.130.052/0001-59");
        jtfdCnpj.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jtfdCnpjKeyReleased(evt);
            }
        });
        jPanel1.add(jtfdCnpj, new org.netbeans.lib.awtextra.AbsoluteConstraints(410, 80, 140, 20));

        jLabel4.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jLabel4.setText("CNPJ:");
        jPanel1.add(jLabel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(410, 60, 60, 20));

        jtfdCelular.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jtfdCelular.setText("(88)8888-8888");
        jtfdCelular.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jtfdCelularKeyReleased(evt);
            }
        });
        jPanel1.add(jtfdCelular, new org.netbeans.lib.awtextra.AbsoluteConstraints(320, 120, 100, 20));

        jLabel5.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jLabel5.setText("Celular:");
        jPanel1.add(jLabel5, new org.netbeans.lib.awtextra.AbsoluteConstraints(320, 100, 50, 20));

        jtfdCpf.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jtfdCpf.setText("888.888.888-88");
        jtfdCpf.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jtfdCpfKeyReleased(evt);
            }
        });
        jPanel1.add(jtfdCpf, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 120, 100, 20));

        jLabel6.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jLabel6.setText("CPF:");
        jPanel1.add(jLabel6, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 100, 60, 20));

        jtfdRg.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jtfdRg.setText("1285241037");
        jtfdRg.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jtfdRgKeyReleased(evt);
            }
        });
        jPanel1.add(jtfdRg, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 120, 100, 20));

        jLabel8.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jLabel8.setText("RG:");
        jPanel1.add(jLabel8, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 100, 60, 20));

        jtfdTelefone.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jtfdTelefone.setText("(88)8888-8888");
        jtfdTelefone.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jtfdTelefoneKeyReleased(evt);
            }
        });
        jPanel1.add(jtfdTelefone, new org.netbeans.lib.awtextra.AbsoluteConstraints(560, 40, 100, 20));

        jLabel9.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jLabel9.setText("Telefone:");
        jPanel1.add(jLabel9, new org.netbeans.lib.awtextra.AbsoluteConstraints(560, 20, 60, 20));

        jLabel11.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jLabel11.setText("Fax:");
        jPanel1.add(jLabel11, new org.netbeans.lib.awtextra.AbsoluteConstraints(430, 100, 60, 20));

        jtfdFax.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jtfdFax.setText("(88)8888-8888");
        jtfdFax.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jtfdFaxKeyReleased(evt);
            }
        });
        jPanel1.add(jtfdFax, new org.netbeans.lib.awtextra.AbsoluteConstraints(430, 120, 120, 20));

        jLabel13.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jLabel13.setText("Contato:");
        jPanel1.add(jLabel13, new org.netbeans.lib.awtextra.AbsoluteConstraints(560, 100, 60, 20));

        jtfdContato.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jtfdContato.setText("(88)8888-8888");
        jtfdContato.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jtfdContatoKeyReleased(evt);
            }
        });
        jPanel1.add(jtfdContato, new org.netbeans.lib.awtextra.AbsoluteConstraints(560, 120, 100, 20));

        jLabel14.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jLabel14.setText("Data Cadastro:");
        jPanel1.add(jLabel14, new org.netbeans.lib.awtextra.AbsoluteConstraints(560, 60, 100, 20));

        jtfdDataCadastro.setEditable(false);
        jtfdDataCadastro.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jtfdDataCadastro.setText("88/88/8888");
        jtfdDataCadastro.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jtfdDataCadastroKeyReleased(evt);
            }
        });
        jPanel1.add(jtfdDataCadastro, new org.netbeans.lib.awtextra.AbsoluteConstraints(560, 80, 100, 20));

        jPanel4.setBackground(new java.awt.Color(214, 229, 233));
        jPanel4.setBorder(javax.swing.BorderFactory.createEtchedBorder(java.awt.Color.gray, new java.awt.Color(51, 153, 255)));
        jPanel4.setLayout(null);

        jtfdBairro.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jtfdBairro.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jtfdBairroKeyReleased(evt);
            }
        });
        jPanel4.add(jtfdBairro);
        jtfdBairro.setBounds(10, 60, 240, 20);

        jtfdEndereco.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jtfdEndereco.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jtfdEnderecoKeyReleased(evt);
            }
        });
        jPanel4.add(jtfdEndereco);
        jtfdEndereco.setBounds(10, 20, 460, 20);

        jLabel15.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jLabel15.setText("Rua:");
        jPanel4.add(jLabel15);
        jLabel15.setBounds(10, 0, 28, 20);

        jtfdCidade.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jtfdCidade.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jtfdCidadeKeyReleased(evt);
            }
        });
        jPanel4.add(jtfdCidade);
        jtfdCidade.setBounds(260, 60, 310, 20);

        jLabel17.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jLabel17.setText("Cidade:");
        jPanel4.add(jLabel17);
        jLabel17.setBounds(260, 40, 60, 20);

        jLabel18.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jLabel18.setText("UF:");
        jPanel4.add(jLabel18);
        jLabel18.setBounds(580, 40, 30, 20);

        jtfdUf.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jtfdUf.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jtfdUfKeyReleased(evt);
            }
        });
        jPanel4.add(jtfdUf);
        jtfdUf.setBounds(580, 60, 40, 20);

        jtfdCep.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jtfdCep.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jtfdCepKeyReleased(evt);
            }
        });
        jPanel4.add(jtfdCep);
        jtfdCep.setBounds(480, 20, 140, 20);

        jLabel19.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jLabel19.setText("CEP:");
        jPanel4.add(jLabel19);
        jLabel19.setBounds(480, 0, 30, 20);

        jLabel20.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jLabel20.setText("Bairro:");
        jPanel4.add(jLabel20);
        jLabel20.setBounds(10, 40, 90, 20);

        jPanel1.add(jPanel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 150, 630, 90));

        jtaObs.setColumns(20);
        jtaObs.setRows(5);
        jtaObs.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jtaObsKeyReleased(evt);
            }
        });
        jScrollPane2.setViewportView(jtaObs);

        jPanel1.add(jScrollPane2, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 260, 630, 50));

        jLabel16.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jLabel16.setText("Observação:");
        jPanel1.add(jLabel16, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 240, 90, 20));

        jPanel2.setBackground(new java.awt.Color(217, 228, 231));
        jPanel2.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(102, 0, 255)));

        jbtnCancelar.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jbtnCancelar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icones/can.png"))); // NOI18N
        jbtnCancelar.setMnemonic('L');
        jbtnCancelar.setText("Cancelar");
        jbtnCancelar.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        jbtnCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtnCancelarActionPerformed(evt);
            }
        });

        jbtnExcluir.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jbtnExcluir.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icones/excluir25.png"))); // NOI18N
        jbtnExcluir.setMnemonic('I');
        jbtnExcluir.setText("Excluir");
        jbtnExcluir.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        jbtnExcluir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtnExcluirActionPerformed(evt);
            }
        });

        jbtnSalvar.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jbtnSalvar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icones/atualizar25.png"))); // NOI18N
        jbtnSalvar.setMnemonic('t');
        jbtnSalvar.setText("Salvar");
        jbtnSalvar.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        jbtnSalvar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtnSalvarActionPerformed(evt);
            }
        });

        jbtnNovo.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jbtnNovo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icones/incl.png"))); // NOI18N
        jbtnNovo.setMnemonic('x');
        jbtnNovo.setText("Novo");
        jbtnNovo.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        jbtnNovo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtnNovoActionPerformed(evt);
            }
        });

        jbtnPrimeiro.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jbtnPrimeiro.setText("<<");
        jbtnPrimeiro.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        jbtnPrimeiro.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtnPrimeiroActionPerformed(evt);
            }
        });

        jbtnAnterior.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jbtnAnterior.setText("<");
        jbtnAnterior.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        jbtnAnterior.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtnAnteriorActionPerformed(evt);
            }
        });

        jbtnProximo.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jbtnProximo.setText(">");
        jbtnProximo.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        jbtnProximo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtnProximoActionPerformed(evt);
            }
        });

        jbtnUltimo.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jbtnUltimo.setText(">>");
        jbtnUltimo.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        jbtnUltimo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtnUltimoActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jbtnNovo, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jbtnSalvar, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jbtnCancelar, javax.swing.GroupLayout.PREFERRED_SIZE, 112, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jbtnExcluir, javax.swing.GroupLayout.PREFERRED_SIZE, 107, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jbtnPrimeiro, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jbtnAnterior, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jbtnProximo, javax.swing.GroupLayout.PREFERRED_SIZE, 46, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jbtnUltimo, javax.swing.GroupLayout.DEFAULT_SIZE, 54, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jbtnPrimeiro, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jbtnAnterior, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jbtnUltimo, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jbtnNovo, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jbtnSalvar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jbtnCancelar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jbtnExcluir, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addComponent(jbtnProximo, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(31, 31, 31)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGap(34, 34, 34))
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 710, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGap(15, 32, Short.MAX_VALUE)
                    .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, 680, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(0, 33, Short.MAX_VALUE)))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 176, Short.MAX_VALUE)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 321, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGap(45, 45, 45)
                    .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, 172, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(0, 398, Short.MAX_VALUE)))
        );

        pack();
        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        java.awt.Dimension dialogSize = getSize();
        setLocation((screenSize.width-dialogSize.width)/2,(screenSize.height-dialogSize.height)/2);
    }// </editor-fold>//GEN-END:initComponents

    private void jtfdPesquisaKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtfdPesquisaKeyReleased
        if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
            jbtnPesquisarActionPerformed(null);
        }
    }//GEN-LAST:event_jtfdPesquisaKeyReleased

    private void jtblPesquisaMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jtblPesquisaMouseClicked
        jtfdCodigo.setText((String) jtblPesquisa.getValueAt(jtblPesquisa.getSelectedRow(), 0));
        jtfdNome.setText((String) jtblPesquisa.getValueAt(jtblPesquisa.getSelectedRow(), 1));
        jtfdTelefone.setText((String) jtblPesquisa.getValueAt(jtblPesquisa.getSelectedRow(), 2));
        jtfdEmail.setText((String) jtblPesquisa.getValueAt(jtblPesquisa.getSelectedRow(), 3));
        jtfdCelular.setText((String) jtblPesquisa.getValueAt(jtblPesquisa.getSelectedRow(), 4));
        jtfdFax.setText((String) jtblPesquisa.getValueAt(jtblPesquisa.getSelectedRow(), 5));
        jtfdCnpj.setText((String) jtblPesquisa.getValueAt(jtblPesquisa.getSelectedRow(), 6));
        jtfdContato.setText((String) jtblPesquisa.getValueAt(jtblPesquisa.getSelectedRow(), 7));
        jtfdRg.setText((String) jtblPesquisa.getValueAt(jtblPesquisa.getSelectedRow(), 8));
        jtfdOrgao.setText((String) jtblPesquisa.getValueAt(jtblPesquisa.getSelectedRow(), 9));
        jtfdCpf.setText((String) jtblPesquisa.getValueAt(jtblPesquisa.getSelectedRow(), 10));
        jtfdEndereco.setText((String) jtblPesquisa.getValueAt(jtblPesquisa.getSelectedRow(), 11));
        jtfdBairro.setText((String) jtblPesquisa.getValueAt(jtblPesquisa.getSelectedRow(), 12));
        jtfdCidade.setText((String) jtblPesquisa.getValueAt(jtblPesquisa.getSelectedRow(), 13));
        jtfdUf.setText((String) jtblPesquisa.getValueAt(jtblPesquisa.getSelectedRow(), 14));
        jtfdCep.setText((String) jtblPesquisa.getValueAt(jtblPesquisa.getSelectedRow(), 15));
        jtfdDataCadastro.setText((String) jtblPesquisa.getValueAt(jtblPesquisa.getSelectedRow(), 16)); 
        jtaObs.setText((String) jtblPesquisa.getValueAt(jtblPesquisa.getSelectedRow(), 17));
    }//GEN-LAST:event_jtblPesquisaMouseClicked

    private void jtblPesquisaKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtblPesquisaKeyReleased
        jtblPesquisaMouseClicked(null);
    }//GEN-LAST:event_jtblPesquisaKeyReleased

    private void jbtnPesquisarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnPesquisarActionPerformed
        if ((jcbxPesquisa.getSelectedItem() == "Código") && (jtfdPesquisa.getText().equals(""))) {
            JOptionPane.showMessageDialog(null, "Informe o Código!");
            jtfdCodigo.requestFocus();
        } else {
            String iPesquisa = jtfdPesquisa.getText();
            int iOpcao = 0;
            switch(jcbxPesquisa.getSelectedIndex()){
                case 0: iOpcao = IFornecedor.SQL_CODIGO; break;
                case 1: iOpcao = IFornecedor.SQL_NOME;break;
                case 2: iOpcao = IFornecedor.SQL_CIDADE;break;
                case 3: iOpcao = IFornecedor.SQL_CNPJ;break;
                case 4: iOpcao = IFornecedor.SQL_CPF;break;
                case 5: iOpcao = IFornecedor.SQL_DATA_CADASTRO;break;         
            }   
            atualizarDadosTable(fornecedorCtrl.pesquisar(iOpcao, iPesquisa));
        }
    }//GEN-LAST:event_jbtnPesquisarActionPerformed

    private void jtfdNomeKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtfdNomeKeyReleased
        if (!jbtnCancelar.isEnabled()) {
            habilitaDesabilitaBotoes(false);
        }
    }//GEN-LAST:event_jtfdNomeKeyReleased

    private void jbtnCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnCancelarActionPerformed
        limpaTela();
    }//GEN-LAST:event_jbtnCancelarActionPerformed

    private void jbtnExcluirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnExcluirActionPerformed
        String[] botoes = {"Sim", "Não"};
        int n = JOptionPane.showOptionDialog(this, "Tem certeza que deseja excluir o item?",
                "Apagar ?", JOptionPane.DEFAULT_OPTION,
                JOptionPane.QUESTION_MESSAGE, null, botoes, botoes[0]);
        if (n == 0) {
            fornecedorCtrl.excluir(Integer.parseInt(jtfdCodigo.getText()));
            limpaTela();
        } 
    }//GEN-LAST:event_jbtnExcluirActionPerformed

    private void jbtnSalvarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnSalvarActionPerformed
        int codigoAtual = Integer.parseInt(jtfdCodigo.getText());
        String nome = jtfdNome.getText();   
        String bairro = jtfdBairro.getText();
        String celular = jtfdCelular.getText();
        String cep = jtfdCep.getText();        
        String cidade = jtfdCidade.getText();
        String cnpj = jtfdCnpj.getText();
        String contato = jtfdContato.getText();
        String cpf = jtfdCpf.getText();        
        String email = jtfdEmail.getText();        
        String endereco = jtfdEndereco.getText();
        String fax = jtfdFax.getText();
        String telefone = jtfdTelefone.getText(); 
        String obs = jtaObs.getText();
        String orgaorg = jtfdOrgao.getText();                       
        String rg = jtfdRg.getText();       
        String uf = jtfdUf.getText();
        Date dataCadastro = mDate.stringToDate(jtfdDataCadastro.getText(),"dd/MM/yyyy");        
        
        if (codigoAtual > 0) {
            fornecedorCtrl.atualizar(codigoAtual, nome, endereco, email, bairro, cidade, cep, uf, telefone, 
                    celular, cpf, obs, rg, orgaorg, dataCadastro, cnpj, fax, contato, 
                    "USUÁRIO -  "+mDate.dateToString(mDate.getDataAtual(),"dd/MM/yyyy EEE HH:mm:ss")+" - ALTERAÇÃO");
        }else{     
            fornecedorCtrl.inserir(codigoAtual, nome, endereco, email, bairro, cidade, cep, uf, telefone, 
                    celular, cpf, obs, rg, orgaorg, dataCadastro, cnpj, fax, contato, 
                    "USUÁRIO -  "+mDate.dateToString(mDate.getDataAtual(),"dd/MM/yyyy EEE HH:mm:ss")+" - INCLUSÃO");
            jtfdCodigo.setText(String.valueOf(fornecedorCtrl.getCodigo()));            
        }      
        habilitaDesabilitaBotoes(true);       
    }//GEN-LAST:event_jbtnSalvarActionPerformed

    private void jbtnNovoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnNovoActionPerformed
        limpaTela();            
        jtfdNome.requestFocus();
        jtfdCodigo.setText("0");
        jtfdDataCadastro.setText(mDate.dateToString(mDate.getDataAtual(),"dd/MM/yyyy"));
        habilitaDesabilitaBotoes(false);       
    }//GEN-LAST:event_jbtnNovoActionPerformed

    private void jbtnPrimeiroActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnPrimeiroActionPerformed
        jtblPesquisa.setRowSelectionInterval(0, 0);
        jtblPesquisaMouseClicked(null);
    }//GEN-LAST:event_jbtnPrimeiroActionPerformed

    private void jbtnAnteriorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnAnteriorActionPerformed
        int linhaSelecionada = jtblPesquisa.getSelectedRow();
        if (linhaSelecionada > 0) {
            jtblPesquisa.setRowSelectionInterval(linhaSelecionada - 1, linhaSelecionada - 1);
            jtblPesquisaMouseClicked(null);
        }
    }//GEN-LAST:event_jbtnAnteriorActionPerformed

    private void jbtnProximoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnProximoActionPerformed
        int linhaSelecionada = jtblPesquisa.getSelectedRow();
        int totalLinhas = jtblPesquisa.getRowCount();
        if (linhaSelecionada < (totalLinhas - 1)) {
            jtblPesquisa.setRowSelectionInterval(linhaSelecionada + 1, linhaSelecionada + 1);
            jtblPesquisaMouseClicked(null);
        }
    }//GEN-LAST:event_jbtnProximoActionPerformed

    private void jbtnUltimoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnUltimoActionPerformed
        int totalLinhas = jtblPesquisa.getRowCount();
        jtblPesquisa.setRowSelectionInterval(totalLinhas - 1, totalLinhas - 1);
        jtblPesquisaMouseClicked(null);
    }//GEN-LAST:event_jbtnUltimoActionPerformed

    private void jtfdOrgaoKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtfdOrgaoKeyReleased
        jtfdNomeKeyReleased(evt);
    }//GEN-LAST:event_jtfdOrgaoKeyReleased

    private void jtfdEmailKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtfdEmailKeyReleased
        jtfdNomeKeyReleased(evt);
    }//GEN-LAST:event_jtfdEmailKeyReleased

    private void jtfdCnpjKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtfdCnpjKeyReleased
        jtfdNomeKeyReleased(evt);
    }//GEN-LAST:event_jtfdCnpjKeyReleased

    private void jtfdCelularKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtfdCelularKeyReleased
        jtfdNomeKeyReleased(evt);
    }//GEN-LAST:event_jtfdCelularKeyReleased

    private void jtfdCpfKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtfdCpfKeyReleased
        jtfdNomeKeyReleased(evt);
    }//GEN-LAST:event_jtfdCpfKeyReleased

    private void jtfdRgKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtfdRgKeyReleased
        jtfdNomeKeyReleased(evt);
    }//GEN-LAST:event_jtfdRgKeyReleased

    private void jtfdTelefoneKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtfdTelefoneKeyReleased
        jtfdNomeKeyReleased(evt);
    }//GEN-LAST:event_jtfdTelefoneKeyReleased

    private void jtfdFaxKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtfdFaxKeyReleased
        jtfdNomeKeyReleased(evt);
    }//GEN-LAST:event_jtfdFaxKeyReleased

    private void jtfdContatoKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtfdContatoKeyReleased
        jtfdNomeKeyReleased(evt);
    }//GEN-LAST:event_jtfdContatoKeyReleased

    private void jtfdDataCadastroKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtfdDataCadastroKeyReleased
        jtfdNomeKeyReleased(evt);
    }//GEN-LAST:event_jtfdDataCadastroKeyReleased

    private void jtfdEnderecoKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtfdEnderecoKeyReleased
        jtfdNomeKeyReleased(evt);
    }//GEN-LAST:event_jtfdEnderecoKeyReleased

    private void jtfdBairroKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtfdBairroKeyReleased
        jtfdNomeKeyReleased(evt);
    }//GEN-LAST:event_jtfdBairroKeyReleased

    private void jtfdCidadeKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtfdCidadeKeyReleased
        jtfdNomeKeyReleased(evt);
    }//GEN-LAST:event_jtfdCidadeKeyReleased

    private void jtfdUfKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtfdUfKeyReleased
        jtfdNomeKeyReleased(evt);
    }//GEN-LAST:event_jtfdUfKeyReleased

    private void jtfdCepKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtfdCepKeyReleased
        jtfdNomeKeyReleased(evt);
    }//GEN-LAST:event_jtfdCepKeyReleased

    private void jtaObsKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtaObsKeyReleased
        jtfdNomeKeyReleased(evt);
    }//GEN-LAST:event_jtaObsKeyReleased

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JSeparator jSeparator12;
    private javax.swing.JSeparator jSeparator13;
    private javax.swing.JButton jbtnAnterior;
    private javax.swing.JButton jbtnCancelar;
    private javax.swing.JButton jbtnExcluir;
    private javax.swing.JButton jbtnNovo;
    private javax.swing.JButton jbtnPesquisar;
    private javax.swing.JButton jbtnPrimeiro;
    private javax.swing.JButton jbtnProximo;
    private javax.swing.JButton jbtnSalvar;
    private javax.swing.JButton jbtnUltimo;
    private javax.swing.JComboBox jcbxPesquisa;
    private javax.swing.JTextArea jtaObs;
    private javax.swing.JTable jtblPesquisa;
    private javax.swing.JTextField jtfdBairro;
    private javax.swing.JTextField jtfdCelular;
    private javax.swing.JTextField jtfdCep;
    private javax.swing.JTextField jtfdCidade;
    private javax.swing.JTextField jtfdCnpj;
    private javax.swing.JTextField jtfdCodigo;
    private javax.swing.JTextField jtfdContato;
    private javax.swing.JTextField jtfdCpf;
    private javax.swing.JTextField jtfdDataCadastro;
    private javax.swing.JTextField jtfdEmail;
    private javax.swing.JTextField jtfdEndereco;
    private javax.swing.JTextField jtfdFax;
    private javax.swing.JTextField jtfdNome;
    private javax.swing.JTextField jtfdOrgao;
    private javax.swing.JTextField jtfdPesquisa;
    private javax.swing.JTextField jtfdRg;
    private javax.swing.JTextField jtfdTelefone;
    private javax.swing.JTextField jtfdUf;
    // End of variables declaration//GEN-END:variables

    private void limpaTela(){
        jtfdCodigo.setText("0");
        jtfdNome.setText(null);
        jtfdTelefone.setText(null);
        jtfdEmail.setText(null);
        jtfdCelular.setText(null);
        jtfdFax.setText(null);
        jtfdCnpj.setText(null);
        jtfdContato.setText(null);
        jtfdRg.setText(null);
        jtfdOrgao.setText(null);
        jtfdCpf.setText(null);
        jtfdEndereco.setText(null);
        jtfdBairro.setText(null);
        jtfdCidade.setText(null);
        jtfdUf.setText(null);
        jtfdCep.setText(null);
        jtfdDataCadastro.setText(null); 
        jtaObs.setText(null);       
        habilitaDesabilitaBotoes(true);        
    }
    
    public void inserirDadosTable(ArrayList list){ 
        DefaultTableModel modelo = new DefaultTableModel(new String[]{"Código","Nome","Telefone","E-mail","Celular",
           "Fax","CNPJ","Contato","RG","Orgão RG","CPF","Rua","Bairro","Cidade","UF","CEP","Data Cadastro","Observação","Auditoria"}, 0);             
        jtblPesquisa.setModel(modelo);               
        for (int i = 0; i < list.size(); i++) {
            modelo.addRow((String[])list.get(i));            
        }
    }  
    
    private void atualizarDadosTable(){ 
        ArrayList list;
        list = fornecedorCtrl.getAll();
        inserirDadosTable(list);
    }
    
    private void atualizarDadosTable(ArrayList list){ 
        inserirDadosTable(list);    
    }
    
    private void inserirDadosCombo(){        
        jcbxPesquisa.setModel(new DefaultComboBoxModel(new String[]{"Código"}));            
        jcbxPesquisa.addItem("Nome");            
        jcbxPesquisa.addItem("Cidade");            
        jcbxPesquisa.addItem("CNPJ");            
        jcbxPesquisa.addItem("CPF");
        jcbxPesquisa.addItem("Data Cadastro");                  
    }
    
    private void habilitaDesabilitaBotoes(boolean Habilita){        
        jbtnPrimeiro.setEnabled(Habilita);
        jbtnAnterior.setEnabled(Habilita);
        jbtnProximo.setEnabled(Habilita);
        jbtnUltimo.setEnabled(Habilita);
        jbtnNovo.setEnabled(Habilita);
        jbtnSalvar.setEnabled(!Habilita);
        jbtnCancelar.setEnabled(!Habilita);
        jbtnExcluir.setEnabled(Habilita);
        jbtnPesquisar.setEnabled(Habilita);        
    }  
    
    private void icoTitle(){
        java.net.URL imgURL = UnidadeGUI.class.getResource("/icones/ico_barra.png");
        setIconImage(new ImageIcon(imgURL).getImage());
    }
    
    private void atualizarDados(){
        inserirDadosCombo();
        atualizarDadosTable();
    }
    
    public void criarTela(){
        initComponents();
        setVisible(true);
        habilitaDesabilitaBotoes(true);        
        atualizarDados();
        icoTitle();
    }

    @Override
    public void update() {
        atualizarDados();
    } 
}